#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : bigDataProject 
@File    : shop_api.py
@IDE     : PyCharm 
@Author  : Mario
@Date    : 2022/11/14 14:07 
@Describe: 中台运营门店相关接口
"""
from typing import Text

from api.middle_api.base_middle_api import BaseMiddleAPI
from utils.common.common_control import get_shop_code


class ShopAPI(BaseMiddleAPI):

    def __init__(self, env: Text, brand_code: Text):
        super().__init__(env)
        self.brand_code = brand_code

    def get_shop_info(self):
        """获取门店信息"""
        shop_code = get_shop_code(self.brand_code)
        payload = '{"brandCode":"' + self.brand_code + '","shopCode":"' + shop_code + '"}'
        response = self.http_request('catering-backend/shop/base/list', payload, "中台获取门店信息")
        return response

    def get_shop_table_code(self, tableCode):
        """
        获取门店台位列表信息
        :param tableCode: 台位号
        :return:
        """
        shop_code = get_shop_code(self.brand_code)
        payload = '{"pageNum":1,"pageSize":10,"shopCode":"' + shop_code + '","tableCode":"' + tableCode + '"}'
        response = self.http_request('catering-backend/shop/table/list', payload, "中台获取门店台位列表信息")
        return response


if __name__ == '__main__':
    test = ShopAPI('823882', "sit")
    test.get_shop_info()
